home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6959 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.9 KB

  1. Path: news.ov.com!news
  2. From: glenn@ov.com (Fletcher.Glenn@ov.com)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Big and little endians
  5. Date: 16 Feb 1996 18:44:00 GMT
  6. Organization: OpenVision
  7. Message-ID: <4g2j9g$ir2@spanky.pls.ov.com>
  8. References: <4fuuqq$fpp@due.unit.no>
  9. Reply-To: glenn@ov.com
  10. NNTP-Posting-Host: foghorn.pls.ov.com
  11.  
  12. In article fpp@due.unit.no, Vidar Moe <vidarm@ibt.unit.no> writes:
  13. >What exactly is meant by the terms little-endians and 
  14. >big-endians?
  15. >
  16. >Vidar Moe.
  17. >
  18. >
  19.  
  20. First of all, the terms are derived from Johnathon Swift's "Gulliver's
  21. Travels" referring to the reason behind the war between Lilliput and
  22. Blefesceu.  These two cities were warring over which end of a soft
  23. boiled egg should be opened to eat it.  One city said the "big end" and
  24. the other said the "little end".  The terms now are used to refer to
  25. those who defend a dogma without good reason.
  26.  
  27. As it applies to computers, the terms refer to the ordering of bytes
  28. in a computer word.  Dec and Intel use the "Big-Endian" order, and
  29. Motorola and SPARC use the "Little-Endian" order.
  30.  
  31. The "Little-Endian" order places the lowest addressed byte in the high
  32. end of the word, and then next higher addressed byte to the next lower
  33. position.  Thus if you examine a string in memory, you will see the
  34. bytes in the same order as they would appear in a word.
  35.  
  36. In ancient times, word size and byte ordering would be detected by sending
  37. a 4 character word.  The UNIX world used the word UNIX.  The receiving
  38. end would examine the word, and if it got UNIX, then the machines had
  39. the same byte ordering.  If the machine got XINU, then
  40. the word size was 4 bytes, but the byte order was opposite (the other
  41. endian).  Similarly, if the word was NUXI then the word size was two
  42. bytes and opposite byte ordering.  Clearly, you could not detect the
  43. difference between 2 byte and 4 byte words if the machines had the
  44. same byte ordering.
  45.  
  46.             Fletcher.Glenn@ov.com
  47.  
  48.